﻿<script src="~/Content/jquery.min.js"></script>
<link href="~/Content/bootstrap-theme.css" rel="stylesheet" />

<table  border="0" cellpadding="0" cellspacing="0">
    <thead>

        <tr>
            <td>编号</td>
            <td>账户</td>
            <td>密码</td>
            <td>角色(1:超级管理员，0：普通管理员)</td>
        </tr>

    </thead>
    <tbody id="sysuserTable">
     
    </tbody>
</table>
<script type="text/javascript">
    $(function () {
        LoadSysusers();
       
    });

    function LoadSysusers()
    {
        $.getJSON("/api/values", function (data)
        {
            $("#sysuserTable").html("");
            $.each(data, function (key, val)
            {
                var row =
                    "<tr><td>" + val.username + "</td><td>" + val.pwd + "</td><td>" + val.role + "</td></tr>"
                $("#sysuserTable").append(row)
            })
        })

    } 

    

    function InsertSysuser(evt)
    {
        console.info("开始新增");
        var data =
        {
            username: $("#username").val(),
            pwd: $("#pwd").val(),
            role: $("#role").val(),
        }

        $.post("/api/values",data, function (data)
        {
           $("#username").val(''),
            $("#pwd").val(''),
            $("#role").val(''),
          
                alert("1");
            LoadSysusers();

        })

          
         }
</script>


<fieldset>
    <legend>新增</legend>
    姓名：<input type="text" id="username" /><br />
    密码：<input type="text" id="pwd" /><br />
    角色：<input type="text" id="role" /><br />
    <input type="button" value="新增" onclick="InsertSysuser()"/>
</fieldset>